#ifndef _BOARD_H_
#define _BOARD_H_

#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include "./cust/bsp/inc/bsp_common.h"
#include "./cust/bsp/inc/uos.h"
#include "./cust/bsp/inc/cpu.h"
#include "./cust/bsp/inc/sdkfs.h"
#include "./cust/bsp/inc/atchan.h"
#include "./cust/bsp/inc/misc.h"
#include "./cust/bsp/inc/mci_audio.h"
#include "./cust/bsp/inc/sdkAudioHAL.h"
#include "./cust/bsp/inc/sdkcommpm.h"
#include "./cust/bsp/inc/sdkningbo.h"
#include "./cust/bsp/inc/sdkcharger_api.h"
#include "./cust/bsp/inc/sdkptable.h"
#include "./cust/bsp/inc/sdkpartition_ops.h"
#include "./cust/bsp/inc/mfpr_api.h"
#include "./cust/bsp/inc/sdkbt.h"
#include "./cust/bsp/inc/sdkcamera.h"
#include "./framework/hal/media/external_codecs/jpglib/include/jpeglib.h"
#include "lv_drivers/common/lv_pm.h"
#include "ril/ril.h"

typedef enum
{
    INTC_RC_OK = 1,

    INTC_RC_INVALID_SRC = -100,
    INTC_RC_NOT_AVAILABLE,
    INTC_RC_NO_ISR_BOUND,
    INTC_RC_ISR_ALREADY_BOUND,
    INTC_RC_BAD_ISR_PARAMETER,
    INTC_RC_NULL_POINTER,
    INTC_RC_PRIORITY_TABLE_ERROR,
    INTC_RC_WRONG_PARAMETER		// cover all cases of wrong configuration setting
}INTC_ReturnCode;

#define PM_RESUME_ONKEY   (0x1 << 0)
#define PM_RESUME_ALARM   (0x1 << 1)
#define PM_RESUME_SDK     (0x1 << 2)
#define PM_RESUME_UI      (0x1 << 3)
#define PM_RESUME_USB     (0x1 << 4)
#define PM_RESUME_OVP     (0x1 << 5) /* pmic uv irq 13*/
#define PM_RESUME_ENDKEY     (0x1 << 6)
#define PM_RESUME_NORMALKEY     (0x1 << 7) /* all key except onkey/endkey */
#define PM_RESUME_AMBIENT     (0x1 << 8) /* ambient 1 min timeout to wake up gui */
#define PM_RESUME_VAD     (0x1 << 9) /*voice*/
#define PM_RESUME_ALL     (PM_RESUME_ONKEY|PM_RESUME_ALARM|PM_RESUME_SDK|PM_RESUME_UI|PM_RESUME_USB|PM_RESUME_OVP|PM_RESUME_ENDKEY|PM_RESUME_NORMALKEY|PM_RESUME_AMBIENT|PM_RESUME_VAD)

void pmic_vibrator_on(void);
void pmic_vibrator_off(void);

typedef unsigned char BOOL;
typedef int (*Usb_PlugCallback)(unsigned int action);
typedef unsigned int (*Sim_CallCallback)(unsigned int SimId);
typedef int (*Battery_Callback)(unsigned char bcs,unsigned char bcl,unsigned short batLevel);
extern BOOL ChargerCallbackRegister(Usb_PlugCallback Usb_charger_status,Sim_CallCallback get_call_status,Battery_Callback battery_status);
extern BOOL pm_BatteryInit(void);
extern BOOL pm_BatteryMonitorProc(void);

// others
void sys_pm_init(void);
uint32_t sys_pm_set_state(int state);

extern int pm_state_flag;
#ifdef USE_WATCH_LITE
extern int te_flag_ref;
#define LCD_TE_COME   (0x1 << 0)
#endif
uint32_t tick_to_ms(uint32_t tick);
void board_power_off(int type);
int startup_silent_reset(void);
uint8_t AudioHAL_SetResBufCnt(unsigned int bufCnt);
typedef void (*AUDIOHAL_SpeakerPA_T) (uint32_t on);
void AudioHAL_AifBindSpeakerPA_CB(AUDIOHAL_SpeakerPA_T cb);

extern BOOL PMIC_IS_PM812(void);
extern BOOL PMIC_IS_PM813(void);
extern BOOL PMIC_IS_PM813S(void);
extern BOOL PMIC_IS_PM813_A1(void);
extern BOOL PMIC_IS_PM813_A2(void);
extern BOOL PMIC_IS_PM813_A3(void);
extern BOOL PMIC_IS_PM802(void);
extern BOOL PMIC_IS_PM803(void);

extern int cplog_printf(const char *fmt, ...);

void pmic_init(void);
int pmic_get_type(void);
void lcd_backlight_ctrl(int level);
int oled_panel_mapping_backlight_level(int level);
extern BOOL GetAmbientStatusBeforeReset(void);
extern void ambient_status_set(BOOL status);
extern void mipi_panel_save_backlight(int panel_type, int status, int level);
extern uint8_t GetBacklightLevelBeforeReset(void);
extern BOOL GetBacklightStatusBeforeReset(void);
extern void GuilinLite_Ldo_6_set_2_8(void);
extern void GuilinLite_Ldo_6_set(BOOL OnOff);
typedef int(*dma_callback_t)(uint32_t);
void lcdc_resume(void);

extern int partition_ops_read(const char * pname,
    uint32_t offset ,
    uint32_t length ,
    char * buf_addr);

/** import from cp beg*/
typedef  enum
{
    TCR_1,                              // non drowsy TCR
    TCR_2,                              // non drowsy TCR
    TCR_3,                              // non drowsy TCR

    TCR_4, MAX_HW_TCR_NUMBER = TCR_4, TCR_EXT = TCR_4,
    TCR_5,
    TCR_6,

    MAX_TCR_NUMBER

}TCR_NUMBER;
#define TS_TIMER_ID     TCR_2

void lcd_ldo11_1v2_on(void);
void lcd_ldo11_1v2_off(void);

extern const unsigned char bt_update[];
extern const unsigned int bt_update_len;
extern const unsigned char build_ram_only[];
extern const unsigned int build_ram_only_len;

extern const unsigned char heron_califw[];
extern const unsigned int heron_califw_len;
extern const unsigned char heron_fmacfw[];
extern const unsigned int heron_fmacfw_len;

extern uint32_t i2c_pinmux_cfgs[4][4];

extern void pmic_user_defined_flags_set(uint8_t flag);
extern uint8_t pmic_user_defined_flags_get(void);

bool usb_is_connected(void);

int is_chip_3603(void);
unsigned int lcd_get_dev_id(void);
void lcd_set_dev_id(unsigned int id);
#endif
